package com.gax;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

/**
 * @author GAX
 * @date ${DATE}
 */

// @SpringBootApplication 包括三个注解：
//      @SpringBootConfiguration
//      @EnableAutoConfiguration
//      @ComponentScan
@SpringBootApplication
@MapperScan("com.gax.mapper")
public class Main {

    public static void main(String[] args) {
        System.out.println("这是 dev02 分支的开发");
        System.out.println("zgy zgy");
        System.out.println("这是 dev01 分支的开发");
        System.out.println("gaxgax");
        SpringApplication.run(Main.class,args);
    }

    // 配置 mybatis-plus 插件

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 分页
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        // 乐观锁
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        // 防全局修改和删除
        interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
        return interceptor;
    }
}